{{ define "admin/config/index.html" }}
{{ template "layouts/header.html" .}}
<body style="background-color: #FFFFFF">
<div class="layui-fluid" style="padding-bottom: 45px;">
    <div class="layui-card ">
        <div class="layui-card-body">
            <div id="baseForm" lay-filter="baseForm" class="layui-form  layui-row model-form">
                <div class="layui-tab layui-tab-brief" overflow="">

                    <ul class="layui-tab-title">
                        <li class="layui-this">网站设置</li>
                        <li class="">核心设置</li>
                        <span class="layui-unselect layui-tab-bar" lay-stope="tabmore">
                                <i lay-stope="tabmore" class="layui-icon"></i>
                            </span>
                    </ul>

                    <!-- // 基础设置开始 -->
                    <div class="layui-tab-content">

                        <div class="layui-tab-item layui-show">

                            <div class="layui-form-item ">
                                <label class="layui-form-label">网站名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="site_name" autocomplete="off"
                                           value="{{ .config.site_name }}" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux"><i class="layui-icon layui-icon-about"
                                                                              lay-tips="* 网站的标题，适用于全站变量"></i></div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">网站域名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="site_url" autocomplete="off" value="{{ .config.site_url }}"
                                           class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux"> * 不带HTTP网站地址。</div>
                            </div>

                            <!--                            <div class="layui-form-item">-->
                            <!--                                <label class="layui-form-label">站点LOGO</label>-->
                            <!--                                <div class="layui-input-inline">-->
                            <!--                                    <input type="text" name="site_logo" value="/static/images/logo.png"-->
                            <!--                                           placeholder="请上传站点LOGO图" class="layui-input logo">-->
                            <!--                                </div>-->
                            <!--                                <button type="button" class="layui-btn layui-btn-normal" lay-upload="logo"-->
                            <!--                                        data-url="/admin/ajax/upload?action=logo">-->
                            <!--                                    <i class="layui-icon layui-icon-upload"></i>上传图片-->
                            <!--                                </button>-->
                            <!--                                <input class="layui-upload-file" type="file" accept="" name="file">-->
                            <!--                            </div>-->

                            <!--                            <div class="layui-form-item">-->
                            <!--                                <div class="layui-input-block">-->
                            <!--                                    <div class="layui-upload-logo">-->
                            <!--                                        <dl>-->
                            <!--                                            <dt>-->
                            <!--                                                <img class="logo" src="/static/images/logo.png" alt="站点LOGO">-->
                            <!--                                            </dt>-->
                            <!--                                            <dd class="layui-badge" id="delLogo">删除</dd>-->
                            <!--                                        </dl>-->
                            <!--                                    </div>-->
                            <!--                                </div>-->
                            <!--                            </div>-->
                            <div class="layui-form-item">
                                <label class="layui-form-label">备案信息</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="site_icp" autocomplete="off" value="{{ .config.site_icp }}"
                                           class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">站长邮箱</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="site_email" autocomplete="off"
                                           value="{{ .config.site_email }}" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux"><i class="layui-icon layui-icon-about"
                                                                              lay-tips="* 用于接受系统反馈邮件，可以单独设置！"></i>
                                </div>
                            </div>

                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">关键字</label>
                                <div class="layui-input-block">
                                    <input type="text" name="site_keyword" autocomplete="off" value="{{ .config.site_keyword }}"
                                           class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">网站描述</label>
                                <div class="layui-input-block">
                                    <input type="text" name="site_description" autocomplete="off" value="{{ .config.site_description }}"
                                           class="layui-input">
                                </div>
                            </div>

                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">统计代码</label>
                                <div class="layui-input-block">
                                        <textarea name="site_total" class="layui-textarea"
                                                  placeholder="请输入第三方统计代码">{{ .config.site_total }}</textarea>
                                </div>
                            </div>
                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">版权信息</label>
                                <div class="layui-input-block">
                                    <textarea name="site_copyright" class="layui-textarea"
                                              placeholder="请输入网站版权信息">{{ .config.site_copyright }}</textarea>
                                </div>
                            </div>

                        </div>
                        <!-- // 核心设置开始 -->
                        <div class="layui-tab-item">

                            <div class="layui-form-item">
                                <label class="layui-form-label">加密KEY</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="auth_key" autocomplete="off" value="{{ .config.auth_key }}"
                                           class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">
                                    <i class="layui-icon layui-icon-vercode" lay-tips="* 系统全局加密的KEY，初始化安装自动生成！"></i>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">缓存开关</label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="cache_status" data-display="cache_status"
                                           lay-filter="radioStatus" value="1" title="开启" checked="">
                                    <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                            class="layui-anim layui-icon layui-icon-radio"></i>
                                        <div>开启</div>
                                    </div>
                                    <input type="radio" name="cache_status" data-display="cache_status"
                                           lay-filter="radioStatus" value="0" title="关闭">
                                    <div class="layui-unselect layui-form-radio"><i
                                            class="layui-anim layui-icon layui-icon-circle"></i>
                                        <div>关闭</div>
                                    </div>
                                </div>
                                <div class="layui-form-mid layui-word-aux">* 开启数据库缓存会提高网站性能！</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">关闭网站</label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="site_status" value="1" title="是">
                                    <div class="layui-unselect layui-form-radio"><i
                                            class="layui-anim layui-icon layui-icon-circle"></i>
                                        <div>是</div>
                                    </div>
                                    <input type="radio" name="site_status" value="0" title="否" >
                                    <div class="layui-unselect layui-form-radio layui-form-radioed"><i
                                            class="layui-anim layui-icon layui-icon-radio"></i>
                                        <div>否</div>
                                    </div>
                                </div>
                                <div class="layui-form-mid layui-word-aux">* 关闭网站，全站会显示关闭提示！</div>
                            </div>

                            <div class="layui-form-item layui-col-md5">
                                <label class="layui-form-label">提示信息</label>
                                <div class="layui-input-block">
                                    <textarea name="site_notice" lay-verify="siteClose" class="layui-textarea">{{ .config.site_notice }}</textarea>
                                </div>
                            </div>
                        </div>

                    </div>
                    <div class="layui-form-item text-center model-form-footer">
                        <input type="button" class="layui-btn" lay-submit lay-filter="submit"
                               id="layuiadmin-app-form-submit" value="立即保存">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['layer', 'index', 'form'], function () {
            var $ = layui.$
                , form = layui.form
                , layer = layui.layer;

            var cache_status = {{.config.cache_status}}
            $("input[name=cache_status][value=0]").prop("checked",cache_status==0?true:false)
            $("input[name=cache_status][value=1]").prop("checked",cache_status==1?true:false)

            var site_status = {{.config.site_status}}
            $("input[name=site_status][value=0]").prop("checked",site_status==0?true:false)
            $("input[name=site_status][value=1]").prop("checked",site_status==1?true:false)
            form.render();

            //事件-提交
            form.on('submit(submit)', function (data) {
                console.log("dddd")
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                $.ajax({
                    url: "/admin/config/update",
                    method: "POST",
                    datatype: 'json',
                    data: JSON.stringify(data.field),
                    contentType: "application/json", //发送至服务器的类型
                    success: function (res) {
                        if (res.code == 0) {
                            layer.msg(res.msg, {
                                icon: 1,
                                time: 1500,
                            }, function () {
                                window.location.reload(); //刷新父页面
                            });
                        } else {
                            layer.msg(res.msg, {
                                icon: 5,
                                time: 1500
                            });
                        }
                    },
                    error: function () {
                        layer.msg("添加失败");
                    }
                });
            });
        })
    </script>

</div>
</body>
{{ end }}